<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Checks if a language tag filter matches with locale</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="locale.composelocale.html">« Locale::composeLocale</a></li>
      <li style="float: right;"><a href="locale.getallvariants.html">Locale::getAllVariants »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.locale.html">Locale</a></li>
    <li>Checks if a language tag filter matches with locale</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="locale.filtermatches" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Locale::filterMatches</h1>
  <h1 class="refname">locale_filter_matches</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.0, PHP 7, PHP 8, PECL intl &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">Locale::filterMatches</span> -- <span class="refname">locale_filter_matches</span> &mdash; <span class="dc-title">Checks if a language tag filter matches with locale</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-locale.filtermatches-description">
  <h3 class="title">说明</h3>
  <p class="para">
   面向对象风格
  </p>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><strong>Locale::filterMatches</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$languageTag</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$locale</code></span>, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$canonicalize</code><span class="initializer"> = <strong><code>false</code></strong></span></span>): <span class="type"><span class="type">?</span><span class="type">bool</span></span></div>

  <p class="para rdfs-comment">
   过程化风格
  </p>
  <div class="methodsynopsis dc-description"><span class="methodname"><strong>locale_filter_matches</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$languageTag</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$locale</code></span>, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$canonicalize</code><span class="initializer"> = <strong><code>false</code></strong></span></span>): <span class="type"><span class="type">?</span><span class="type">bool</span></span></div>

  <p class="para rdfs-comment">
   Checks if a <code class="parameter">languageTag</code> filter matches with <code class="parameter">locale</code> according to RFC 4647&#039;s
   basic filtering algorithm
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-locale.filtermatches-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">languageTag</code></dt>

     <dd>

      <p class="para">
       The language tag to check
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">locale</code></dt>

     <dd>

      <p class="para">
       The language range to check against
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">canonicalize</code></dt>

     <dd>

     <p class="para">
      If true, the arguments will be converted to canonical form before
      matching.
     </p>
     </dd>

    
   </dl>

  </p>
 </div>



 <div class="refsect1 returnvalues" id="refsect1-locale.filtermatches-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   <strong><code>true</code></strong> if <code class="parameter">locale</code> matches <code class="parameter">languageTag</code> <strong><code>false</code></strong> otherwise.
  </p>
  <p class="para">当 <code class="parameter">locale</code> 的长度超过 <strong><code>INTL_MAX_LOCALE_LEN</code></strong> 时返回 <strong><code>null</code></strong>。</p>
 </div>


 <div class="refsect1 examples" id="refsect1-locale.filtermatches-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-2332">
   <p><strong>示例 #1 <span class="function"><strong>locale_filter_matches()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">echo&nbsp;(</span><span style="color: #0000BB">locale_filter_matches</span><span style="color: #007700">(</span><span style="color: #DD0000">'de-DEVA'</span><span style="color: #007700">,</span><span style="color: #DD0000">'de-DE'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">false</span><span style="color: #007700">))&nbsp;?&nbsp;</span><span style="color: #DD0000">"Matches"&nbsp;</span><span style="color: #007700">:&nbsp;</span><span style="color: #DD0000">"Does&nbsp;not&nbsp;match"</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #DD0000">';&nbsp;'</span><span style="color: #007700">;<br />echo&nbsp;(</span><span style="color: #0000BB">locale_filter_matches</span><span style="color: #007700">(</span><span style="color: #DD0000">'de-DE_1996'</span><span style="color: #007700">,</span><span style="color: #DD0000">'de-DE'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">false</span><span style="color: #007700">))&nbsp;?&nbsp;</span><span style="color: #DD0000">"Matches"&nbsp;</span><span style="color: #007700">:&nbsp;</span><span style="color: #DD0000">"Does&nbsp;not&nbsp;match"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
  <div class="example" id="example-2333">
   <p><strong>示例 #2 OO example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">echo&nbsp;(</span><span style="color: #0000BB">Locale</span><span style="color: #007700">::</span><span style="color: #0000BB">filterMatches</span><span style="color: #007700">(</span><span style="color: #DD0000">'de-DEVA'</span><span style="color: #007700">,</span><span style="color: #DD0000">'de-DE'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">false</span><span style="color: #007700">))&nbsp;?&nbsp;</span><span style="color: #DD0000">"Matches"&nbsp;</span><span style="color: #007700">:&nbsp;</span><span style="color: #DD0000">"Does&nbsp;not&nbsp;match"</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #DD0000">';&nbsp;'</span><span style="color: #007700">;<br />echo&nbsp;(</span><span style="color: #0000BB">Locale</span><span style="color: #007700">::</span><span style="color: #0000BB">filterMatches</span><span style="color: #007700">(</span><span style="color: #DD0000">'de-DE-1996'</span><span style="color: #007700">,</span><span style="color: #DD0000">'de-DE'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">false</span><span style="color: #007700">))&nbsp;?&nbsp;</span><span style="color: #DD0000">"Matches"&nbsp;</span><span style="color: #007700">:&nbsp;</span><span style="color: #DD0000">"Does&nbsp;not&nbsp;match"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
  <p class="para">以上例程会输出：</p>
  <div class="example-contents screen">
<div class="cdata"><pre>
Does not match; Matches
</pre></div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-locale.filtermatches-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="locale.lookup.html" class="function" rel="rdfs-seeAlso">locale_lookup()</a> - Searches the language tag list for the best match to the language</span></li>
   </ul>
  </p>
 </div>

</div></div></div></body></html>